// import com.alibaba.druid.DbType;
// import com.alibaba.druid.sql.ast.*;
// import com.alibaba.druid.sql.visitor.SQLASTVisitor;

// import java.util.ArrayList;
// import java.util.List;

#include "SQLDropTypeStatement.h"
#include "../../visitor/SQLASTVisitor.h"

SQLDropTypeStatement::SQLDropTypeStatement()
{
}

SQLDropTypeStatement::SQLDropTypeStatement(DbType_ptr dbType)
    : SQLStatementImpl(dbType)
{
}

// @Override
void SQLDropTypeStatement::accept0(SQLASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(SQLDropTypeStatement)))
  {
    acceptChild(visitor, name);
  }
  visitor->endVisit(SharedObject(SQLDropTypeStatement));
}

SQLName_ptr SQLDropTypeStatement::getName()
{
  return name;
}

void SQLDropTypeStatement::setName(SQLName_ptr x)
{
  if (x != nullptr)
  {
    x->setParent(SharedObject(SQLDropTypeStatement));
  }
  this->name = x;
}

BOOL_ptr SQLDropTypeStatement::isIfExists()
{
  return ifExists;
}

void SQLDropTypeStatement::setIfExists(BOOL_ptr ifExists)
{
  this->ifExists = ifExists;
}

// @Override
SQLObject_list_ptr SQLDropTypeStatement::getChildren()
{
  SQLObject_list_ptr children = std::make_shared<std::list<SQLObject_ptr>>();
  if (name != nullptr)
  {
    children->push_back(name);
  }
  return children;
}

BOOL_ptr SQLDropTypeStatement::replace(SQLExpr_ptr expr, SQLExpr_ptr target)
{
  if (name == expr)
  {
    setName(std::dynamic_pointer_cast<SQLName>(target));
    return BOOL::TRUE;
  }

  return BOOL::FALSE;
}

// @Override
SQLDDLStatement::DDLObjectType SQLDropTypeStatement::getDDLObjectType()
{
  return SQLDDLStatement::DDLObjectType::TYPE;
}
